import React, { Component } from 'react'
import { Button } from 'antd';
import { seetingHandle, addCount, sub } from '../../actions/setting'
import { connect } from 'react-redux'
import { Redirect } from 'react-router-dom'
const mapState = (state) => ({
    ...state,
})
@connect(mapState, { seetingHandle, addCount, sub })
class Settings extends Component {
    constructor() {
        super()
    }
    static getDerivedStateFromProps(props, propsNext) {
    }
    // 手动获取设置的数据
    handleSeeting = () => {
        const data = {
            id: 1,
            name: 'zs'
        };
        this.props.seetingHandle(data)
    }

    // 点击加好
    add = () => {
        this.props.addCount();
        this.setState()
    }

    // 减法
    sub = () => {
        this.props.sub();
        this.setState()
    }

    render() {
        const { nums } = this.props.seeting
        return (
            <div>
                <Button type="primary" onClick={this.handleSeeting}>点击测试</Button>
                <Button type="primary" onClick={this.add}>加法</Button>
                <Button type="primary" onClick={this.sub}>减法</Button>
                <h1>{nums}</h1>
            </div>
        )
    }
}
export default Settings